import request from "../utils/request";

import {
  IRoleSimple,
  RoleListResponse,
  IAddRoleParams,
  IEditRoleParams,
  IPermission,
} from "../types/role";

export default {
  // 获取角色列表
  getRoleList(params?: {
    pageNum: number;
    pageSize: number;
    roleName?: string;
  }) {
    return request.get<RoleListResponse>("/roles/list", params);
  },
  // 编辑角色
  editRole(data: IEditRoleParams) {
    return request.post("/roles/edit", data);
  },
  // 获取所有角色-alllist
  getAllRoleList() {
    return request.get<IRoleSimple[]>("/roles/allList");
  },
  // 新增角色
  addRole(data: IAddRoleParams) {
    return request.post("/roles/create", data);
  },
  // 删除角色
  deleteRole(data: { _id: string }) {
    return request.post("/roles/delete", data);
  },
  // 设置权限
  setPermission(data: IPermission) {
    return request.post("/roles/update/permission", data);
  },
};
